﻿using System;
using VitCode.Castle.Entities;

namespace AMS.Inventory.Entities
{
    public class PlanInfo
    {
        public static string STATE_NOT_START="NotStart",STATE_DOING="Doing",STATE_FINISH="Finish";
        public static string SELECT_ASSET_LIST_SQL = "SelectAssetListSql", SELECTED_ASSET_LIST_SQL = "SelectedAssetListSql";
        protected User m_Responsible;
        protected DateTime m_CreateDate;
        protected DateTime m_FinishDate;
        protected Guid m_Id;
        protected DateTime m_StartDate;
        protected string m_Name;

        public PlanInfo()
        {
            
        }

        /// <summary>
        /// 状态
        /// </summary>
        public virtual string State
        {
            get;
            set;
        }

        /// <summary>
        /// 备注
        /// </summary>
        public virtual string Memo
        {
            get;
            set;
        }

        /// <summary>
        /// 计划名称
        /// </summary>
        public virtual string Name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }

        /// <summary>
        /// 数据唯一键
        /// </summary>
        public virtual Guid Id
        {
            get { return m_Id; }
            set { m_Id = value; }
        }

        /// <summary>
        /// 创建时间
        /// </summary>
        public virtual DateTime CreateDate
        {
            get { return m_CreateDate; }
            set { m_CreateDate = value; }
        }

        /// <summary>
        /// 计划开始时间
        /// </summary>
        public virtual DateTime StartDate
        {
            get { return m_StartDate; }
            set { m_StartDate = value; }
        }


        /// <summary>
        /// 计划终止时间
        /// </summary>
        public virtual DateTime FinishDate
        {
            get { return m_FinishDate; }
            set { m_FinishDate = value; }
        }


        /// <summary>
        /// 负责人
        /// </summary>
        public virtual User Responsible
        {
            get { return m_Responsible; }
            set { m_Responsible = value; }
        }

        /// <summary>
        /// 单计划最大资产量
        /// </summary>
        private int m_MaxAssetAmount = 1000;

        public virtual int MaxAssetAmount
        {
            get { return m_MaxAssetAmount; }
            set { m_MaxAssetAmount = value; }
        }


        /// <summary>
        /// 重写Equals方法
        /// </summary>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(obj, this))
                return true;
            if (obj == null)
                return false;

            //var sObj = obj as InventoryInfo;
            //return sObj != null && (sObj.Id == m_Id);

            var sObj = obj as PlanInfo;
            return sObj != null && ((sObj.Name == m_Name) || sObj.Id == m_Id);

        }

        /// <summary>
        /// 重写GetHashCode方法
        /// </summary>
        public override int GetHashCode()
        {
            int hash = 199;
            hash = 15 * hash * m_Id.GetHashCode();
            return hash;
        }

        public virtual void SetSysExPro()
        {
            if (m_Id == Guid.Empty)
            {
                m_CreateDate = DateTime.Now;
                State = STATE_NOT_START;
            }
        }

    }
}